home *** CD-ROM | disk | FTP | other *** search
-
- # (C) Copyright 1995 by Michael Coulter. All rights reserved.
- ##########################################################################
- # Functions:
- # check_return expected_value exit_value exit_message
- # check_cmd function: check_cmd exit_status cmd arg...
- # report_error expected_status message
-
- # USAGE: check_return expected_value exit_value exit_message
- function check_return
- {
- RETURN_STATUS=$?
- if [ "$RETURN_STATUS" -ne "$1" ]
- then
- echo "Expected status $1 got ${RETURN_STATUS}." >&2
- echo "$3" >&2
- exit "$2"
- fi
- }
-
- # check_cmd function: check_cmd exit_status cmd arg...
- #
- function check_cmd
- {
- EXIT_STATUS="$1"; shift
- COMMAND="$@"
- "$@"
- check_return 0 "$EXIT_STATUS" "Error with command: $COMMAND"
- }
-
- # report_error expected_status message
- # if $? is not expecte_status, print message to stderr and
- # increment NBR_ERRORS
- function report_error
- {
- REPORT_ERROR_STATUS=$?
- if [ $REPORT_ERROR_STATUS -ne "$1" ]
- then
- echo "$2" >&2
- NBR_ERRORS=$$(($NBR_ERRORS + 1))
- fi
- }
- NBR_ERRORS=0
-